This is a simple helper notebook to quickly get some numbers about your graphs out of a Neo4j database. You just need to start your Neo4j database locally with the default values before running this notebook.
First, we fire up the connection to Neo4j that contains all the data. If needed, you could add some custom parameters like URL or port to adjust the setup to your settings.
In [9]:
import py2neo
import pandas as pd
graph = py2neo.Graph()
graph.dbms.kernel_version
Out[9]:
Let's get some numbers!
In [10]:
graph.data("MATCH (n) RETURN COUNT(n) AS NumberOfAllNodes")
Out[10]:
In [16]:
pd.DataFrame(graph.data("MATCH (n) RETURN labels(n) AS Labels, COUNT(n) AS LabelCount ORDER BY LabelCount DESC"))
Out[16]:
In [12]:
graph.data("MATCH ()-[r]-() RETURN COUNT(r) AS NumberOfAllRelationships")
Out[12]:
In [13]:
pd.DataFrame(graph.data("MATCH ()-[r]-() RETURN type(r) AS Type, COUNT(r) AS TypeCount ORDER BY TypeCount DESC"))
Out[13]:
In [14]:
graph.data("MATCH (n) RETURN SUM(SIZE(KEYS(n))) as NumberOfAllProperties")
Out[14]:
In [15]:
pd.DataFrame(graph.data("""
MATCH (n) WITH KEYS(n) as keys
UNWIND keys as properties
RETURN properties as Property, COUNT(properties) as PropertyCount
ORDER BY PropertyCount DESC"""))
Out[15]: